-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Menu item API #79
Menu item API #79
Conversation
@tehsmeely, thank you for your attempt to make the better implementation! 👍 Just one question. Have you seen another attempt? Could you please compare yours with that? One of the advantages that I see here is that there are no generics, which makes it easier to use. However, the UserData type is lost here, which is a disadvantage. |
As far as I'm aware there's little to no need for userdata handling here as that's primarily the C handling for generic callback functions. Since we're using rust closures in this implementation, we can include any relevant userdata into that thunk and continue from there. |
I just pushed a fix for a soundness issue where one could drop a MenuItem and result in the item still being visible in the menu, at which point pressing would result in reading of unmanaged memory. Worked around this by forcing the "removeMenuItem" call in the drop impl for MenuItem instead. The
|
Exposes an api in
System
for adding (etc) menu items.Slightly painful since it involves passing callbacks into C but it's handled by double-boxing dynamic Fn() trait objects.
There's some degree of code around handling the possible kinds of MenuItem values (as MenuItemKind).
Potentially one could go a step further so users do not have the directly deal with the index value and can get
its typed (bool or string) accordingly.
Adds a new example that adds one of each menu item